<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 18.3.&nbsp; Special Input Characters</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch18lev1sec2.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch18lev1sec4.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch18lev1sec3"></a>
<h3 class="docSection1Title" id="454331-992">18.3. Special Input Characters</h3>
<p class="docText"><a name="idd1e135814"></a><a name="idd1e135817"></a><a name="idd1e135820"></a><a name="idd1e135823"></a><a name="idd1e135826"></a><a name="idd1e135829"></a><a name="idd1e135832"></a><a name="idd1e135835"></a><a name="idd1e135838"></a><a name="idd1e135843"></a><a name="idd1e135848"></a><a name="idd1e135851"></a><a name="idd1e135856"></a><a name="idd1e135859"></a><a name="idd1e135862"></a><a name="idd1e135865"></a><a name="idd1e135870"></a><a name="idd1e135873"></a><a name="idd1e135876"></a><a name="idd1e135879"></a><a name="idd1e135882"></a><a name="idd1e135885"></a><a name="idd1e135888"></a><a name="idd1e135891"></a><a name="idd1e135896"></a><a name="idd1e135901"></a><a name="idd1e135906"></a><a name="idd1e135911"></a><a name="idd1e135916"></a><a name="idd1e135921"></a><a name="idd1e135926"></a><a name="idd1e135931"></a><a name="idd1e135936"></a><a name="idd1e135941"></a><a name="idd1e135946"></a><a name="idd1e135951"></a><a name="idd1e135956"></a><a name="idd1e135961"></a><a name="idd1e135966"></a><a name="idd1e135971"></a><a name="idd1e135976"></a><a name="idd1e135981"></a>POSIX.1 defines 11 characters that are handled specially on input. Implementations define additional special characters. <a class="docLink" href="#ch18fig09">Figure 18.9</a> summarizes these special characters.</P>
<a name="ch18fig09"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 18.9. Summary of special terminal input characters</H5></caption><colgroup><col width="50"><col width="50"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"><col width="40"></colgroup><thead><TR><th class="rightBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Character</span></P></th><th class="rightBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="rightBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman"><tt>c_cc</tt> subscript</span></P></th><th class="rightBorder thead" scope="col" align="center" valign="middle" colspan="2"><p class="docText"><span class="docEmphRoman">Enabled by</span></P></th><th class="rightBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Typical value</span></P></th><th class="rightBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">POSIX.1</span></p></th><th class="thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></P></th><th class="thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></p></th><th class="thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></P></th><th class="thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Solaris 9</span></P></th></TR><tr><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">field</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="right" valign="middle"><p class="docText"><span class="docEmphRoman">flag</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="rightBorder bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th><th class="bottomBorder thead" scope="col" align="left" valign="top">&nbsp;</th></tr></thead><TR><TD class="rightBorder" align="left" valign="top"><p class="docText">CR</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">carriage return</p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">(can't change)</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText"><tt>\r</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText">DISCARD</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">discard output</p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VDISCARD</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>IEXTEN</tt></P></td><td class="rightBorder" align="center" valign="top"><p class="docText">^O</p></td><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">DSUSP</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">delayed suspend (<tt>SIGTSTP</tt>)</p></td><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VDSUSP</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ISIG</tt></P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">^Y</p></TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText">EOF</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">end of file</p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VEOF</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">^D</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText">EOL</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">end of line</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VEOL</tt></P></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></TD><td class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><TD class="rightBorder" align="left" valign="top"><p class="docText">EOL2</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">alternate end of line</P></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VEOL2</tt></P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></P></TD><TD class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">ERASE</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">backspace one character</p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VERASE</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">^H, ^?</P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText">ERASE2</P></td><td class="rightBorder" align="left" valign="top"><p class="docText">alternate backspace character</p></td><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VERASE2</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">^H, ^?</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top">&nbsp;</TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText">INTR</P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">interrupt signal (<tt>SIGINT</tt>)</P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VINTR</tt></p></TD><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ISIG</tt></p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">^?, ^C</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">KILL</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">erase line</p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VKILL</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">^U</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">LNEXT</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">literal next</p></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VLNEXT</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IEXTEN</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">^V</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText">NL</p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">line feed (newline)</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">(can't change)</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><TD class="rightBorder" align="center" valign="top"><p class="docText"><tt>\n</tt></p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">QUIT</p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">quit signal (<tt>SIGQUIT</tt>)</p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VQUIT</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ISIG</tt></P></td><TD class="rightBorder" align="center" valign="top"><p class="docText">^\</P></TD><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">REPRINT</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">reprint all input</p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VREPRINT</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></td><TD class="rightBorder" align="center" valign="top"><p class="docText">^R</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText">START</P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">resume output</p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VSTART</tt></P></td><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_iflag</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IXON/IXOFF</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">^Q</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD></TR><TR><td class="rightBorder" align="left" valign="top"><p class="docText">STATUS</P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">status request</p></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VSTATUS</tt></P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">^T</p></td><td class="rightBorder" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><td class="docTableCell" align="left" valign="top">&nbsp;</TD><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="left" valign="top">&nbsp;</td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">STOP</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">stop output</p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VSTOP</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_iflag</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>IXON/IXOFF</tt></P></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">^S</p></TD><TD class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText">SUSP</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">suspend signal (<tt>SIGTSTP</tt>)</p></TD><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>VSUSP</tt></p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ISIG</tt></p></td><td class="rightBorder" align="center" valign="top"><p class="docText">^Z</p></td><td class="rightBorder" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></TD><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></td><TD class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</P></TD></tr><TR><td class="rightBorder" align="left" valign="top"><p class="docText">WERASE</P></TD><TD class="rightBorder" align="left" valign="top"><p class="docText">backspace one word</p></TD><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>VWERASE</tt></p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>c_lflag</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>ICANON</tt></p></TD><td class="rightBorder" align="center" valign="top"><p class="docText">^W</P></td><TD class="rightBorder" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td><td class="docTableCell" align="center" valign="top"><p class="docText">&#8226;</p></td></tr></table></p><br>
<p class="docText">Of the 11 POSIX.1 special characters, we can change 9 of them to almost any value that we like. The exceptions are the newline and carriage return characters (<tt>\n</tt> and <tt>\r</tt>, respectively) and perhaps the STOP and START characters (depends on the implementation). To do this, we modify the appropriate entry in the <tt>c_cc</tt> array of the <tt>termios</tt> structure. The elements in this array are referred to by name, with each name beginning with a <tt>V</tt> (the third column in <a class="docLink" href="#ch18fig09">Figure 18.9</a>).</p>
<p class="docText">POSIX.1 allows us to disable these characters. If we set the value of an entry in the <tt>c_cc</tt> array to the value of <tt>_POSIX_VDISABLE</tt>, then we disable the corresponding special character.</P>
<blockquote>
<p class="docText">In older versions of the Single UNIX Specification, support for <tt>_POSIX_VDISABLE</tt> was optional. It is now required.</P>
<p class="docText">All four platforms discussed in this text support this feature. Linux 2.4.22 and Solaris 9 define <tt>_POSIX_VDISABLE</tt> as 0; FreeBSD 5.2.1 and Mac OS X 10.3 define it as <tt>0xff</tt>.</p>
<p class="docText">Some earlier UNIX systems disabled a feature if the corresponding special input character was 0.</P>
</blockquote>
<a name="ch18ex01"></a>
<H5 class="docExampleTitle">Example</H5>
<p class="docText"><a name="idd1e137092"></a><a name="idd1e137097"></a><a name="idd1e137102"></a><a name="idd1e137107"></a><a name="idd1e137112"></a><a name="idd1e137117"></a><a name="idd1e137122"></a><a name="idd1e137127"></a><a name="idd1e137132"></a>Before describing all the special characters in detail, let's look at a small program that changes them. The program in <a class="docLink" href="#ch18fig10">Figure 18.10</a> disables the interrupt character and sets the end-of-file character to Control-B.</p>
<p class="docText">Note the following in this program.</P>
<UL><LI><p class="docList">We modify the terminal characters only if standard input is a terminal device. We call <tt>isatty</tt> (<a class="docLink" href="ch18lev1sec9.html#ch18lev1sec9">Section 18.9</a>) to check this.</p></LI><li><p class="docList">We fetch the <tt>_POSIX_VDISABLE</tt> value using <tt>fpathconf</tt>.</P></LI><LI><p class="docList">The function <tt>tcgetattr</tt> (<a class="docLink" href="ch18lev1sec4.html#ch18lev1sec4">Section 18.4</a>) fetches a <tt>termios</tt> structure from the kernel. After we've modified this structure, we call <tt>tcsetattr</tt> to set the attributes. The only attributes that change are the ones we specifically modified.</p></LI><LI><p class="docList">Disabling the interrupt key is different from ignoring the interrupt signal. The program in <a class="docLink" href="#ch18fig10">Figure 18.10</a> simply disables the special character that causes the terminal driver to generate <tt>SIGINT</tt>. We can still use the <tt>kill</tt> function to send the signal to the process.</p></LI></UL>

<a name="ch18fig10"></a>
<h5 class="docExampleTitle">Figure 18.10. Disable interrupt character and change end-of-file character</h5>

<pre>
#include "apue.h"
#include &lt;termios.h&gt;

int
main(void)
{
    struct termios term;
    long           vdisable;

    if (isatty(STDIN_FILENO) == 0)
        err_quit("standard input is not a terminal device");

    if ((vdisable = fpathconf(STDIN_FILENO, _PC_VDISABLE)) &lt; 0)
        err_quit("fpathconf error or _POSIX_VDISABLE not in effect");

    if (tcgetattr(STDIN_FILENO, &amp;term) &lt; 0) /* fetch tty state */
        err_sys("tcgetattr error");

    term.c_cc[VINTR] = vdisable;    /* disable INTR character */
    term.c_cc[VEOF]  = 2;           /* EOF is Control-B */

    if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &amp;term) &lt; 0)
        err_sys("tcsetattr error");

    exit(0);
}
</pre><br>


<p class="docText"><a name="idd1e137232"></a><a name="idd1e137237"></a><a name="idd1e137240"></a><a name="idd1e137243"></a><a name="idd1e137246"></a><a name="idd1e137249"></a><a name="idd1e137252"></a><a name="idd1e137255"></a><a name="idd1e137258"></a><a name="idd1e137263"></a><a name="idd1e137266"></a><a name="idd1e137271"></a><a name="idd1e137276"></a><a name="idd1e137281"></a><a name="idd1e137286"></a><a name="idd1e137291"></a><a name="idd1e137294"></a><a name="idd1e137299"></a><a name="idd1e137304"></a><a name="idd1e137307"></a><a name="idd1e137310"></a><a name="idd1e137313"></a>We now describe each of the special characters in more detail. We call these the special input characters, but two of the characters, STOP and START (Control-S and Control-Q), are also handled specially when output. Note that when recognized by the terminal driver and processed specially, most of these special characters are then discarded: they are not returned to the process in a read operation. The exceptions to this are the newline characters (NL, EOL, EOL2) and the carriage return (CR).</p>
<P><table cellspacing="0" FRAME="void" RULES="none" cellpadding="5"><colgroup><col width="100"><col width="400"></colgroup><thead></thead><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">CR</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">The carriage return character. We cannot change this character. This character is recognized on input in canonical mode. When both <tt>ICANON</tt> (canonical mode) and <tt>ICRNL</tt> (map CR to NL) are set and <tt>IGNCR</tt> (ignore CR) is not set, the CR character is translated to NL and has the same effect as a NL character. This character is returned to the reading process (perhaps after being translated to a NL).</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText">DISCARD</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">The discard character. This character, recognized on input in extended mode (<tt>IEXTEN</tt>), causes subsequent output to be discarded until another DISCARD character is entered or the discard condition is cleared (see the <tt>FLUSHO</tt> option). This character is discarded when processed (i.e., it is not passed to the process).</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText">DSUSP</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">The delayed-suspend job-control character. This character is recognized on input in extended mode (<tt>IEXTEN</tt>) if job control is supported and if the <tt>ISIG</tt> flag is set. Like the SUSP character, this delayed-suspend character generates the <tt>SIGTSTP</tt> signal that is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec6.html#ch09fig07">Figure 9.7</a>). But the delayed-suspend character generates a signal only when a process reads from the controlling terminal, not when the character is typed. This character is discarded when processed (i.e., it is not passed to the process).</P></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText">EOF</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">The end-of-file character. This character is recognized on input in canonical mode (<tt>ICANON</tt>). When we type this character, all bytes waiting to be read are immediately passed to the reading process. If no bytes are waiting to be read, a count of 0 is returned. Entering an EOF character at the beginning of the line is the normal way to indicate an end of file to a program. This character is discarded when processed in canonical mode (i.e., it is not passed to the process).</P></TD></tr><TR><td class="docTableCell" align="left" valign="top"><p class="docText">EOL</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">The additional line delimiter character, like NL. This character is recognized on input in canonical mode (<tt>ICANON</tt>) and is returned to the reading process; however, this character is not normally used.</p></TD></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">EOL2</P></td><td class="docTableCell" align="left" valign="top"><p class="docText">Another line delimiter character, like NL. This character is treated identically to the EOL character.</p></td></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">ERASE</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">The erase character (backspace). This character is recognized on input in canonical mode (<tt>ICANON</tt>) and erases the previous character in the line, not erasing beyond the beginning of the line. This character is discarded when processed in canonical mode (i.e., it is not passed to the process).</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText"><a name="idd1e137449"></a><a name="idd1e137454"></a><a name="idd1e137457"></a><a name="idd1e137460"></a><a name="idd1e137465"></a><a name="idd1e137470"></a><a name="idd1e137475"></a><a name="idd1e137478"></a><a name="idd1e137481"></a><a name="idd1e137484"></a><a name="idd1e137487"></a><a name="idd1e137492"></a>ERASE2</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">The alternate erase character (backspace). This character is treated exactly like the erase character (ERASE).
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText">INTR</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">The interrupt character. This character is recognized on input if the <tt>ISIG</tt> flag is set and generates the <tt>SIGINT</tt> signal that is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec6.html#ch09fig07">Figure 9.7</a>). This character is discarded when processed (i.e., it is not passed to the process).
</P></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText">KILL</P></td><TD class="docTableCell" align="left" valign="top"><p class="docText">The kill character. (The name &quot;kill&quot; is overused; recall the <tt>kill</tt> function used to send a signal to a process. This character should be called the line-erase character; it has nothing to do with signals.) It is recognized on input in canonical mode (<tt>ICANON</tt>). It erases the entire line and is discarded when processed (i.e., it is not passed to the process).
</P></TD></tr><TR><td class="docTableCell" align="left" valign="top"><p class="docText">LNEXT</P></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">The literal-next character. This character is recognized on input in extended mode (<tt>IEXTEN</tt>) and causes any special meaning of the next character to be ignored. This works for all special characters listed in this section. We can use this character to type any character to a program. The LNEXT character is discarded when processed, but the next character entered is passed to the process.
</p></TD></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">NL</P></td><td class="docTableCell" align="left" valign="top"><p class="docText">The newline character, which is also called the line delimiter. We cannot change this character. This character is recognized on input in canonical mode (<tt>ICANON</tt>). This character is returned to the reading process.
</p></td></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">QUIT</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">The quit character. This character is recognized on input if the <tt>ISIG</tt> flag is set. The quit character generates the <tt>SIGQUIT</tt> signal, which is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec6.html#ch09fig07">Figure 9.7</a>). This character is discarded when processed (i.e., it is not passed to the process).
</p></td></tr><tr><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">Recall from <a class="docLink" href="ch10lev1sec2.html#ch10fig01">Figure 10.1</a> that the difference between INTR and QUIT is that the QUIT character not only terminates the process by default, but also generates a <tt>core</tt> file.
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText">REPRINT</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">The reprint character. This character is recognized on input in extended, canonical mode (both <tt>IEXTEN</tt> and <tt>ICANON</tt> flags set) and causes all unread input to be output (reechoed). This character is discarded when processed (i.e., it is not passed to the process).
</p></TD></TR><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">START</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">The start character. This character is recognized on input if the <tt>IXON</tt> flag is set and is automatically generated as output if the <tt>IXOFF</tt> flag is set. A received START character with <tt>IXON</tt> set causes stopped output (from a previously entered STOP character) to restart. In this case, the START character is discarded when processed (i.e., it is not passed to the process).
</P></TD></TR><tr><TD class="docTableCell" align="left" valign="top">&nbsp;</td><TD class="docTableCell" align="left" valign="top"><p class="docText">When <tt>IXOFF</tt> is set, the terminal driver automatically generates a START character to resume input that it had previously stopped, when the new input will not overflow the input buffer.</P></TD></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText"><a name="idd1e137661"></a><a name="idd1e137666"></a><a name="idd1e137669"></a><a name="idd1e137674"></a><a name="idd1e137679"></a><a name="idd1e137684"></a><a name="idd1e137687"></a><a name="idd1e137690"></a><a name="idd1e137695"></a>STATUS</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">The BSD status-request character. This character is recognized on input in extended, canonical mode (both <tt>IEXTEN</tt> and <tt>ICANON</tt> flags set) and generates the <tt>SIGINFO</tt> signal, which is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec6.html#ch09fig07">Figure 9.7</a>). Additionally, if the <tt>NOKERNINFO</tt> flag is not set, status information on the foreground process group is also displayed on the terminal. This character is discarded when processed (i.e., it is not passed to the process).
</p></td></tr><tr><TD class="docTableCell" align="left" valign="top"><p class="docText">STOP</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText">The stop character. This character is recognized on input if the <tt>IXON</tt> flag is set and is automatically generated as output if the <tt>IXOFF</tt> flag is set. A received STOP character with <tt>IXON</tt> set stops the output. In this case, the STOP character is discarded when processed (i.e., it is not passed to the process). The stopped output is restarted when a START character is entered.
</P></td></tr><tr><td class="docTableCell" align="left" valign="top">&nbsp;</td><td class="docTableCell" align="left" valign="top"><p class="docText">When <tt>IXOFF</tt> is set, the terminal driver automatically generates a STOP character to prevent the input buffer from overflowing.
</p></td></tr><tr><td class="docTableCell" align="left" valign="top"><p class="docText">SUSP</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">The suspend job-control character. This character is recognized on input if job control is supported and if the <tt>ISIG</tt> flag is set. The suspend character generates the <tt>SIGTSTP</tt> signal, which is sent to all processes in the foreground process group (refer to <a class="docLink" href="ch09lev1sec6.html#ch09fig07">Figure 9.7</a>). This character is discarded when processed (i.e., it is not passed to the process).
</p></td></tr><TR><TD class="docTableCell" align="left" valign="top"><p class="docText">WERASE</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText">The word-erase character. This character is recognized on input in extended, canonical mode (both <tt>IEXTEN</tt> and <tt>ICANON</tt> flags set) and causes the previous word to be erased. First, it skips backward over any white space (spaces or tabs), then backward over the previous token, leaving the cursor positioned where the first character of the previous token was located. Normally, the previous token ends when a white space character is encountered. We can change this, however, by setting the <tt>ALTWERASE</tt> flag. This flag causes the previous token to end when the first nonalphanumeric character is encountered. The word-erase character is discarded when processed (i.e., it is not passed to the process).</P></td></TR></table></P><BR>
<p class="docText">Another &quot;character&quot; that we need to define for terminal devices is the BREAK character. BREAK is not really a character, but rather a condition that occurs during asynchronous serial data transmission. A BREAK condition is signaled to the device driver in various ways, depending on the serial interface.</p>
<blockquote>
<p class="docText">Most old serial terminals have a key labeled BREAK that generates the BREAK condition, which is why most people think of BREAK as a character. Some newer terminal keyboards don't have a BREAK key. On PCs, the break key might be mapped for other purpose. For example, the Windows command interpreter can be interrupted by typing Control-BREAK.</P>
</blockquote>
<p class="docText">For asynchronous serial data transmission, a BREAK is a sequence of zero-valued bits that continues for longer than the time required to send one byte. The entire sequence of zero-valued bits is considered a single BREAK. In <a class="docLink" href="ch18lev1sec8.html#ch18lev1sec8">Section 18.8</a>, we'll see how to send a BREAK with the <tt>tcsendbreak</tt> function.</p>

<UL></UL></TD></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch18lev1sec2.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch18lev1sec4.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--46-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--46-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
